function bubbleSort(arr){
	for(var i = 0; i < arr.length - 1; i++){
		for(var j = 0; j < arr.length - (i + 1); j++){
			if(arr[j] > arr[j + 1]){
				var tmp = arr[j];
				arr[j] = arr[j + 1];
				arr[j + 1] = tmp;
			}
		}
	}
}

function changeSort(arr){
	for(var i = 0; i < arr.length - 1; i++){
		for(var j = i + 1; j < arr.length; j++){
			if(arr[i] > arr[j]){
				var tmp = arr[i];
				arr[i] = arr[j];
				arr[j] = tmp;
			}
		}
	}
}

function testCode(n){
	var arr = [];
	for(var i = 0; i < n; i++){
		var tmp = parseInt(Math.random() * 123);
		if(tmp >= 0 && tmp <= 9){
			arr.push(tmp);
		}else if(tmp >= 65 && tmp <= 90){
			//大写字母
			var charStr = String.fromCharCode(tmp);
			arr.push(charStr);
		}else if(tmp >= 97 && tmp <= 122){
			var charStr = String.fromCharCode(tmp);
			arr.push(charStr);
		}else{
			i--;
		}
	}
	return arr.join("");
}

			function showTime(){
				var d = new Date();

				var year = d.getFullYear();
				var month = d.getMonth() + 1;
				var date = d.getDate();

				var week = d.getDay();
				week = chineseFromNum(week);

				var hour = doubleNum(d.getHours());
				var min = doubleNum(d.getMinutes());
				var sec = doubleNum(d.getSeconds());

				//字符串拼接
				var str = year + "年" + month + "月" + date + "日 星期" + week + " " + hour + ":" + min + ":" + sec;
				return str;
			}

			function doubleNum(num){
				if(num < 10){
					return "0" + num;
				}else{
					return num;
				}
			}

			//数字转中文的函数
			function chineseFromNum(num){
				switch(num){
					case 1:
						return "一";
						break;
					case 2:
						return "二";
						break;
					case 3:
						return "三";
						break;
					case 4:
						return "四";
						break;
					case 5:
						return "五";
						break;
					case 6:
						return "六";
						break;
					case 0:
						return "日";
						break;
					default:
						console.log("error");
						break;
				}
			}
			function elementsByClassName(node, className){

				var res = [];
				//获取node节点下，所有的节点
				var nodes = node.getElementsByTagName("*");
				for(var i = 0; i < nodes.length; i++){
					if(nodes[i].className === className){
						res.push(nodes[i]);
					}
				}
				return res;
			}

			//跨浏览器的兼容 获取当前有效样式
			function getStyle(node, cssStyle){
				if(node.currentStyle){
					return node.currentStyle[cssStyle];
				}else{
					return getComputedStyle(node)[cssStyle];
				}
			}
			function randomColor(){
				var str = "rgba(" + parseInt(Math.random() * 256) + "," + parseInt(Math.random() * 256) + "," + parseInt(Math.random() * 256) + ",1)";
				return str;
			}
			//忽略空白节点
			function removeSpaceNode(node){
				//<1>找到所有的子节点
				var nodes = node.childNodes;
				for(var i = 0; i < nodes.length; i++){
					if(nodes[i].nodeType == 3 && /^\s+$/.test(nodes[i].nodeValue)){
						node.removeChild(nodes[i]);
					}
				}
			}
			/*
				跨浏览器的阻止事件冒泡
			*/
			function stopBubble(e){
				if(e.cancelBubble){
					e.cancelBubble = true;
				}else{
					e.stopPropagation();
				}
			}
			function drag(node){
				var offsetX = 0;
				var offsetY = 0;

				node.onmousedown = function(ev){
					var e = ev || window.event;
					//记录相对距离
					offsetX = e.clientX - node.offsetLeft;
					offsetY = e.clientY - node.offsetTop;

					//编写拖拽
					document.onmousemove = function(ev){
						var e = ev || window.event;
						var l=(e.clientX - offsetX);
					    var t=(e.clientY - offsetY);
						if(l<=0){
							l=0;
						}
						var windowWidth=document.documentElement.clientWidth||document.body.clientWidth;
						if(l>=windowWidth-node.offsetWidth){
							l=windowWidth-node.offsetWidth;
						}
						if(t<=0){
							t=0;
						}
						var windowHeight=document.documentElement.clientHeight||document.body.clientHeight;
						if(t>=windowHeight-node.offsetHeight){
							t=windowHeight-node.offsetHeight;
						}						
						node.style.left = l+ 'px';
						node.style.top =  t+ 'px';

					}

				}
				document.onmouseup = function(){
					document.onmousemove = null;
				}
			}
			//阻止默认行为
			function preDef(e){
				if(e.preventDefault){
					e.preventDefault();
				}else{
					window.event.returnValue = false; //IE
				}
			}
			//跨浏览器添加事件
			function addEvent(obj, type, fn) {
				if (obj.addEventListener) {
					obj.addEventListener(type, fn, false);  //click
				} else if (obj.attachEvent) {
					obj.attachEvent('on' + type, fn);     //onclick
				}
			}
			//跨浏览器移除事件
			function removeEvent(obj, type, fn) {
				if (obj.removeEventListener) {
					obj.removeEventListener(type, fn, false);
				} else if (obj.detachEvent) {
					obj.detachEvent('on' + type, fn);
				}
			}